package com.aim.util;

/**
 * Created with IntelliJ IDEA.
 * User: User
 * Date: 5/20/14
 * Time: 8:53 PM
 * To change this template use File | Settings | File Templates.
 */
public class UnionRandomBetaGenerator implements TimeGenerator {

    private long range;

    public UnionRandomBetaGenerator(long range) {
        this.range = range;
    }

    @Override
    public long nextTime() {
        return (long) (Math.sqrt(Math.random())*range);
    }

    public double[] createDistribution(int numOfBuckets, int numOfSamples){
        Histogram histogram = new Histogram(0,range,numOfBuckets);
        for (int i = 0; i < numOfSamples; i++) {
            histogram.addValue(nextTime());
        }
        return histogram.getBuckets();
    }
}
